﻿package plugin.roleN.compoment
{
    import __AS3__.vec.*;
    import flash.display.*;
    import morn.core.components.*;
    import plugin.component.*;
    import vo.*;

    public class BaoShiTips extends Sprite
    {
        private var back:Image;
        private var nameLabel:Label;
        private var itemArr:Vector.<FlashItem>;
        private var labelArr:Vector.<Label>;
        private var itemSprite:Sprite;
        public var baseicon:String = "";
        private var cfgItems:Object;
        private var n:int = 0;

        public function BaoShiTips()
        {
            this.cfgItems = ConfigDictionary.data.item;
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this.back = new Image();
            this.back.url = "png.common.cs2_power_bg";
            this.back.sizeGrid = "5,5,5,5";
            this.back.width = 180;
            this.addChild(this.back);
            this.itemSprite = new Sprite();
            this.itemSprite.x = 0;
            this.itemSprite.y = 0;
            this.addChild(this.itemSprite);
            this.nameLabel = new Label();
            this.nameLabel.font = "Simsun";
            this.nameLabel.align = "left";
            this.nameLabel.stroke = "1";
            this.nameLabel.color = "0xef7510";
            this.nameLabel.width = 150;
            this.nameLabel.height = 20;
            this.nameLabel.x = 10;
            this.nameLabel.y = 10;
            this.addChild(this.nameLabel);
            return;
        }// end function

        public function showItem(param1:int, param2:Array) : void
        {
            var _loc_6:FlashItem = null;
            var _loc_7:Label = null;
            var _loc_8:int = 0;
            var _loc_9:Object = null;
            var _loc_10:String = null;
            var _loc_3:Array = [];
            while (this.itemSprite.numChildren > 0)
            {
                
                this.itemSprite.removeChildAt(0);
            }
            this.itemArr = new Vector.<FlashItem>;
            this.labelArr = new Vector.<Label>;
            var _loc_4:int = 0;
            while (_loc_4 < 6)
            {
                
                _loc_6 = new FlashItem(null, 0.6, true, false, null, false, false);
                _loc_6.x = 20;
                _loc_6.y = 40 + _loc_4 * (_loc_6.height + 10);
                _loc_6.data = {icon:this.baseicon};
                this.itemSprite.addChild(_loc_6);
                this.itemArr.push(_loc_6);
                _loc_7 = new Label();
                _loc_7.isHtml = true;
                _loc_7.leading = 3;
                _loc_7.font = "Simsun";
                _loc_7.align = "left";
                _loc_7.stroke = "1";
                _loc_7.color = "0xffe4c7";
                _loc_7.width = 150;
                _loc_7.x = _loc_6.x + _loc_6.width + 10;
                _loc_7.y = _loc_6.y;
                _loc_7.text = "可镶嵌";
                this.itemSprite.addChild(_loc_7);
                this.labelArr.push(_loc_7);
                this.back.height = this.nameLabel.y + this.nameLabel.height + _loc_6.y + _loc_6.height - 10;
                _loc_4++;
            }
            if (param2)
            {
                _loc_8 = 0;
                while (_loc_8 < param2.length)
                {
                    
                    if (param2[_loc_8] != 0)
                    {
                        _loc_3.push(param2[_loc_8]);
                    }
                    _loc_8++;
                }
            }
            var _loc_5:int = 0;
            while (_loc_5 < _loc_3.length)
            {
                
                _loc_9 = ItemObject.create(this.cfgItems[int(_loc_3[_loc_5])]);
                this.itemArr[_loc_5].data = _loc_9;
                _loc_10 = this.getText(_loc_9);
                this.labelArr[_loc_5].height = _loc_8 * 20;
                this.labelArr[_loc_5].text = this.cfgItems[int(_loc_3[_loc_5])].name + "\n" + "<font color=\'#e79e21\'>" + _loc_10 + "</font>";
                _loc_5++;
            }
            switch(param1)
            {
                case 0:
                {
                    this.nameLabel.text = "头盔镶嵌属性";
                    break;
                }
                case 1:
                {
                    this.nameLabel.text = "左戒镶嵌属性";
                    break;
                }
                case 2:
                {
                    this.nameLabel.text = "左手镶嵌属性";
                    break;
                }
                case 3:
                {
                    this.nameLabel.text = "衣服镶嵌属性";
                    break;
                }
                case 4:
                {
                    this.nameLabel.text = "武器镶嵌属性";
                    break;
                }
                case 5:
                {
                    this.nameLabel.text = "项链镶嵌属性";
                    break;
                }
                case 6:
                {
                    this.nameLabel.text = "右戒镶嵌属性";
                    break;
                }
                case 7:
                {
                    this.nameLabel.text = "右手镶嵌属性";
                    break;
                }
                case 8:
                {
                    this.nameLabel.text = "腰带镶嵌属性";
                    break;
                }
                case 9:
                {
                    this.nameLabel.text = "鞋子镶嵌属性";
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function getText(param1:Object) : String
        {
            var _loc_2:String = "";
            if (param1.hp > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("生命上限:" + param1.hp / 100 + "%\n");
            }
            if (param1.mp > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("魔法上限:" + param1.mp / 100 + "%\n");
            }
            if (param1.phyAttMax > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("最大物攻:" + param1.phyAttMax + "\n");
            }
            if (param1.magicAtt > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("最大魔攻:" + param1.magicAttMax + "\n");
            }
            if (param1.phyDef > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("最大物防:" + param1.phyDefMax + "\n");
            }
            if (param1.magicDefMax > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("最大魔防:" + param1.magicDefMax + "\n");
            }
            if (param1.taoAtt > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("最大道攻:" + param1.taoAttMax + "\n");
            }
            if (param1.critRate > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("暴伤:" + param1.critRate + "\n");
            }
            if (param1.critical > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("暴击:" + param1.critical / 100 + "%\n");
            }
            if (param1.pureatk > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("神圣:" + param1.pureatk + "\n");
            }
            if (param1.accurate > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("准确:" + param1.accurate + "\n");
            }
            if (param1.dodge > 0)
            {
                (this.n + 1);
                _loc_2 = _loc_2 + ("闪避:" + param1.dodge + "\n");
            }
            return _loc_2;
        }// end function

    }
}
